package com.yueya.common.action;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;
import com.yueya.common.constant.BaseConstant;

/**
 * 全局拦截器
 */
public class CommonInterceptor implements Interceptor {

	public void intercept(Invocation inv) {

		Controller c = inv.getController();
		String cookieLoginName = c.getCookie(BaseConstant.COOKIE_KEY_LOGINNAME);
		c.setAttr("cookieLoginName", cookieLoginName);
		if (cookieLoginName == null || "".equals(cookieLoginName)) {
			c.render("/WEB-INF/views/basic/login/login.jsp");
		} else {
			inv.invoke();
		}

	}
}
